<script setup>
import { ref } from 'vue'

const formData = ref({
  name: '',
  email: '',
  subject: '',
  message: ''
})

const isSubmitting = ref(false)
const submitMessage = ref('')

const handleSubmit = async () => {
  isSubmitting.value = true
  
  // 模拟表单提交
  setTimeout(() => {
    submitMessage.value = '感谢您的留言！我们会尽快回复您。'
    formData.value = { name: '', email: '', subject: '', message: '' }
    isSubmitting.value = false
  }, 1500)
}

const contactInfo = ref([
  {
    icon: '📧',
    title: '邮箱',
    value: 'hello@modernweb.com',
    link: 'mailto:hello@modernweb.com'
  },
  {
    icon: '📞',
    title: '电话',
    value: '+86 123 4567 8900',
    link: 'tel:+8612345678900'
  },
  {
    icon: '📍',
    title: '地址',
    value: '北京市朝阳区科技园A座1001室',
    link: null
  }
])
</script>

<template>
  <div class="contact">
    <!-- Hero Section -->
    <section class="contact-hero">
      <div class="container">
        <div class="contact-hero-content">
          <h1>联系我们</h1>
          <p>有任何问题或项目需求？我们很乐意为您提供帮助</p>
        </div>
      </div>
    </section>

    <!-- Contact Content -->
    <section class="contact-content">
      <div class="container">
        <div class="contact-grid">
          <!-- Contact Info -->
          <div class="contact-info">
            <h2>联系方式</h2>
            <p>选择最适合您的方式联系我们，我们会在24小时内回复</p>
            
            <div class="contact-methods">
              <div v-for="info in contactInfo" :key="info.title" class="contact-method">
                <div class="contact-icon">{{ info.icon }}</div>
                <div class="contact-details">
                  <h3>{{ info.title }}</h3>
                  <a v-if="info.link" :href="info.link" class="contact-link">{{ info.value }}</a>
                  <span v-else class="contact-text">{{ info.value }}</span>
                </div>
              </div>
            </div>

            <div class="business-hours">
              <h3>工作时间</h3>
              <p>周一至周五: 9:00 - 18:00</p>
              <p>周六: 10:00 - 15:00</p>
              <p>周日: 休息</p>
            </div>
          </div>

          <!-- Contact Form -->
          <div class="contact-form">
            <h2>发送消息</h2>
            <form @submit.prevent="handleSubmit" class="form">
              <div class="form-group">
                <label for="name">姓名 *</label>
                <input 
                  type="text" 
                  id="name" 
                  v-model="formData.name" 
                  required
                  placeholder="请输入您的姓名"
                />
              </div>

              <div class="form-group">
                <label for="email">邮箱 *</label>
                <input 
                  type="email" 
                  id="email" 
                  v-model="formData.email" 
                  required
                  placeholder="请输入您的邮箱"
                />
              </div>

              <div class="form-group">
                <label for="subject">主题 *</label>
                <input 
                  type="text" 
                  id="subject" 
                  v-model="formData.subject" 
                  required
                  placeholder="请输入消息主题"
                />
              </div>

              <div class="form-group">
                <label for="message">消息 *</label>
                <textarea 
                  id="message" 
                  v-model="formData.message" 
                  required
                  rows="5"
                  placeholder="请描述您的需求..."
                ></textarea>
              </div>

              <button 
                type="submit" 
                class="btn btn-primary"
                :disabled="isSubmitting"
              >
                {{ isSubmitting ? '发送中...' : '发送消息' }}
              </button>

              <div v-if="submitMessage" class="submit-message">
                {{ submitMessage }}
              </div>
            </form>
          </div>
        </div>
      </div>
    </section>

    <!-- Map Section -->
    <section class="map-section">
      <div class="map-container">
        <div class="map-placeholder">
          <div class="map-content">
            <span>🗺️</span>
            <p>地图位置</p>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<style scoped>
.contact {
  overflow-x: hidden;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 4rem;
}

/* Hero Section */
.contact-hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 120px 0 80px;
  text-align: center;
}

.contact-hero-content h1 {
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.contact-hero-content p {
  font-size: 1.5rem;
  opacity: 0.9;
}

/* Contact Content */
.contact-content {
  padding: 100px 0;
  background: white;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 6rem;
  align-items: start;
}

.contact-info h2,
.contact-form h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #1a202c;
}

.contact-info p {
  color: #718096;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.contact-methods {
  margin-bottom: 2rem;
}

.contact-method {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.contact-icon {
  font-size: 2rem;
  width: 50px;
  text-align: center;
}

.contact-details h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #1a202c;
}

.contact-link {
  color: #667eea;
  text-decoration: none;
}

.contact-link:hover {
  text-decoration: underline;
}

.contact-text {
  color: #4a5568;
}

.business-hours h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #1a202c;
}

.business-hours p {
  color: #718096;
  margin-bottom: 0.5rem;
}

/* Contact Form */
.form {
  background: #f7fafc;
  padding: 2rem;
  border-radius: 1rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #1a202c;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.btn {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: #667eea;
  color: white;
}

.btn:hover:not(:disabled) {
  background: #5a6fd8;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.submit-message {
  margin-top: 1rem;
  padding: 1rem;
  background: #d1fae5;
  color: #065f46;
  border-radius: 0.5rem;
  text-align: center;
}

/* Map Section */
.map-section {
  background: #f7fafc;
  padding-bottom: 100px;
}

.map-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.map-placeholder {
  height: 400px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.map-content span {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.map-content p {
  font-size: 1.5rem;
  font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
  .contact-hero-content h1 {
    font-size: 2rem;
  }
  
  .contact-hero-content p {
    font-size: 1.25rem;
  }
  
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .contact-info,
  .contact-form {
    text-align: center;
  }
  
  .contact-method {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }
  
  .contact-hero {
    padding: 80px 0 60px;
  }
  
  .contact-content {
    padding: 60px 0;
  }
  
  .map-container {
    padding: 0 1rem;
  }
  
  .map-placeholder {
    height: 300px;
  }
}
</style>